package org.example.seata.common.security.service;

import lombok.Getter;
import org.example.seata.bs.api.entity.account.AccountAuth;
import org.example.seata.common.security.util.SecurityUtil;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.User;

import java.util.Collection;

/**
 * @author hzq
 * @date 2021/12/6 16:11
 */
public class CustomUser extends User {

    /**
     * 认证信息
     */
    @Getter
    private AccountAuth auth;

    public CustomUser(AccountAuth auth, Collection<? extends GrantedAuthority> authorities) {
        super(SecurityUtil.createUnionUsername(auth), auth.getCredentials(), authorities);
        this.auth = auth;
    }
}
